/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

/**
 *
 * @author ronaldoats
 */
public class Security {
    
    public static String User="";

    private static String locked = "qwertyuiopasdfghjklzxcvbnm3748162509|MZNXBCVGHFJDKSLAOPQIWRUEYT";
    private static String unlock = "abcdefghijklmnopqrstuvwxyz1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    public static int unsignedByteToInt(byte b) {
        return (int) b & 0xFF;
    }

    public static void main(String aa[]) throws IOException {
//        byte b1 = new String("h").getBytes()[0];
//        byte[]x=new String("ho").getBytes();
//        System.out.println((int)x[1]);
//        System.out.println(b1);
//        
//        System.out.println(unsignedByteToInt(b1));
//        if (1 == 1) {
//            return;
//        }
        BufferedReader R = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Digite Su password");
        String ps = R.readLine();
        String Lock = LOCKED(ps);
        byte[] bHex = CIFRADOHEX(Lock);

        System.out.println("Su cifrado natural es: " + Lock);

        System.out.println("Su Cifrado exadecimal es: " + bHex);

        System.out.println("Su descifrado es: " + UNLOCKED(new String(bHex)));


    }

    public static byte[] CIFRADOHEX(String Lock) {
        byte[] bHex = new byte[0];
        try {
            bHex = Lock.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return bHex;
    }

    public static String LOCKED(String CD) {
        String NP = "";
        for (int i = 0; i < CD.length(); i++) {
            try {
                NP += locked.charAt(unlock.indexOf(CD.charAt(i)));
            } catch (Exception e) {
                NP += CD.charAt(i);
            }
        }
        return NP;
    }

    public static String UNLOCKED(String CD) {
        String NP = "";
        for (int i = 0; i < CD.length(); i++) {
            try {
                NP += unlock.charAt(locked.indexOf(CD.charAt(i)));
            } catch (Exception e) {
                NP += CD.charAt(i);
            }
        }
        return NP;
    }
}
